import request from '@/utils/request'
import type { ApiResult, BaseIds, PageSchema } from '@/api/api'
import type {
  Tenant,
  TenantAddDTO,
  TenantModDTO,
  TenantQueryDTO,
} from '@/api/system/tenant/type'
const BASE_URL = '/admin/api/v1/system/tenant'
const API = {
  BASE_URL: '/admin/api/v1/system/tenant',
  PAGE_URL: BASE_URL + '/page',
  LIST_URL: BASE_URL + '/list',
  REMOVE_URL: BASE_URL + '/rm',
  CHANGE_STATUS_URL: BASE_URL + '/switch',
}
// 添加租户信息
export const tenantAdd = (data: TenantAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 修改租户信息
export const tenantMod = (data: TenantModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
// 删除租户信息
export const tenantDel = (data: BaseIds) => {
  return request.post<any, ApiResult<unknown>>(API.REMOVE_URL, data)
}
// 查询租户信息
export const tenantList = (data: TenantQueryDTO) => {
  return request.post<any, ApiResult<Tenant[]>>(API.LIST_URL, data)
}
// 查询分页数据
export const tenantQuery = (data: TenantQueryDTO) => {
  return request.post<any, ApiResult<PageSchema<Tenant>>>(API.PAGE_URL, data)
}

export const switchStatus = (id: string) => {
  return request.put<any, ApiResult<unknown>>(API.CHANGE_STATUS_URL + `/${id}`)
}
